<?php
//@session_start();$_SESSION["emp_id"]
include("db/connect.php");

$sqlcountmat="select * from cartmaterial where ordermat_id='0' and mat_id='".$_POST["mat_id"]."'";
$querycountmat=mysql_query($sqlcountmat);
$resultmat=mysql_fetch_array($querycountmat);
if($resultmat["ordermat_id"]==""){
$sql="insert into cartmaterial(mat_id,ordermat_id,mat_max,mat_qty)";
$sql.=" values(".$_POST["mat_id"].",0,".$_POST["mat_qty"].",".$_POST["mat_qty"].")";} 
else{
	$sum=$resultmat["mat_qty"]+$_POST["mat_qty"];
    $sql="update cartmaterial set mat_qty=".$sum." where ordermat_id=0 and mat_id=".$_POST["mat_id"]."";
	}
$query=mysql_query($sql);   

?>